<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\model\Admin;
use think\captcha\Captcha;
class Jingtai extends Controller
{
    public function index(){
        ob_start();
        ini_set('memory_limit','188M');
        ini_set('max_execution_time','0');
        date_default_timezone_set('Asia/Shanghai');
        $sys=getsystem();
        $xingqi = date("w");
        if($sys['jingtai']=='open'){
            $time=unserialize($sys['jingtai_ff']);
            if(in_array($xingqi, $time) || $time[0] == 8) {
                $users = db('users')
                    ->where('activation', 1)->where('recount', 'gt', 0)
                    /*        ->where('id',1)
                            ->whereor('id',211)*/
                    ->field('id,level,mobile,up_userid')
                    ->select();
                foreach ($users as $key => $value) {
                    $money = db('user_level')->where('level', $value['level'])->value('lirun');
                    if ($money > 0) {
                        $arr = day_caps($value['id'], $money, 1);
                        if ($arr[0] > 0) {
                            if ($arr[1] == 1) {
                                $beizhu = "日封顶";
                            } else {
                                $beizhu = $value['mobile'];
                            }
                            jifen(1, $value['id'], $money, 11, 1, $beizhu);
                            bonusdel($value['id'], $arr[0]);
                            bonus6($value['id'], $money);
                            achievement(0, 0, 0, 0, $money, $money, 0, 0, 0, 0, $money);
                        }

                        $up_level = db('users')->where('id', $value['up_userid'])->value('level');
                        $level2 = db('user_level')->where('level', $up_level)->value('b8');
                        $money2 = $level2 / 100 * $money;
                        if ($money2 > 0) {
                            $arr2 = day_caps($value['up_userid'], $money2, 1);
                            if ($arr2[0] > 0) {
                                if ($arr2[1] == 1) {
                                    $beizhu = "日封顶";
                                } else {
                                    $beizhu = $value['mobile'];
                                }
                                jifen(1, $value['up_userid'], $arr2[0], 13, 1, $beizhu);
                                bonusdel($value['up_userid'], $arr[0]);
                                achievement(0, 0, 0, 0, $arr2[0], $arr2[0], 0, 0, 0, 0, 0, $arr2[0]);
                            }
                        }
                    }
                }
            }
        }
    }

}